﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel.Resources.Core;

namespace Wimm.Common
{
    public static class StringCategoryExtentionClass
    {
        public static string GetStringFromResource(this string item, string lang)
        {
            ResourceContext ctx = new Windows.ApplicationModel.Resources.Core.ResourceContext();
            ctx.Languages = new string[] { lang };

            ResourceMap rmap = ResourceManager.Current.MainResourceMap.GetSubtree("Resources");
            string description = string.Empty;
            try
            {
                description = rmap.GetValue((item + ".Text").Replace(".", "/"), ctx).ValueAsString;
            }
            catch (Exception)
            {
                description = "??";
            }
            return description;
        }
    }
}
